package com.bruce.pattern.creational.simplefactory;

import org.junit.Test;

/**
 * Created by bruce on 2018/10/24 19:48
 */
public class MainTest {

    //如果JavaVideo和PythonVideo类和MainTest不在同一个包中,在新建的时候就是导入,
    @Test
    public void test1(){

        Video video = new JavaVideo();
        video.produce();
    }

    //而使用简单工厂模式,即使JavaVideo和PythonVideo类和MainTest不在同一个包中
    //获取对应的实例对象不需要自己使用new而导入到MainTest类所在的包中
    @Test
    public void test2(){
        VideoFactory videoFactory = new VideoFactory();
        Video video = videoFactory.newVideo("java");

        Video video1 = videoFactory.newVideo("python");

        video.produce();
        video1.produce();

    }

    @Test
    public void test3(){
        VideoFactory videoFactory = new VideoFactory();
        Video video = videoFactory.getVideo(JavaVideo.class);
        Video video1 = videoFactory.getVideo(PythonVideo.class);

        video.produce();
        video1.produce();

    }






}
